from django.contrib import admin

# 导入ArticlerPost
from .models import ArticlePost

from .models import ArticleColumn


class ArticlePostAdmin(admin.ModelAdmin):
    # 设置列表可显示的字段
    list_display = ('title', 'author', 'column',
                    'total_views', 'likes', 'created', 'updated')
    # 设置过滤选项
    list_filter = ('column', 'created',)
    # 每页显示条目数
    list_per_page = 5
    # 设置可编辑字段
    list_editable = ('column',)
    # 排除一些不想被编辑的 fields, 没有在列表的不可被编辑
    fields = ('title', 'author', 'tags', 'column', 'avatar', 'abstract', 'body')
    ordering = ('-created',)
    # 显示搜索框，搜索框大小写敏感
    search_fields = ('title',)
# 注册ArticlePost到admin中
admin.site.register(ArticlePost, ArticlePostAdmin)
class ArticleColumnAdmin(admin.ModelAdmin):
    # 设置列表可显示的字段
    list_display = ('title', 'created',)
    # 每页显示条目数
    list_per_page = 5
# 注册文章栏目
admin.site.register(ArticleColumn, ArticleColumnAdmin)
# 修改 admin 页面显示标题
admin.site.site_header = "老鑫头の个人博客"
admin.site.index_title = "后台管理"
admin.site.site_title = "老鑫头の个人博客"
